package realQuestion.jiezi;

import java.util.Scanner;

public class Solution1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
      int n=  scanner.nextInt();
      int m=scanner.nextInt();
      String s=scanner.next();
        for (int i = 0; i <m ; i++) {
            String mingan = scanner.next();
            System.out.println(find(s, mingan));
        }


    }
    public  static  int find(String s,String mingan){
        int count=0;
        int length = s.length();
        int length1 = mingan.length();
        for (int i = 0; i <length; i++) {
            if (i+length1<=length){
                String substring = s.substring(i, i+length1 );
                if (mingan.equals(substring)){
                    count++;
                }
            }


        }
        return  count;


    }


}
